package com.example.demo.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class BaseUtil {

	private static String packageName = "com.example.demo";

	public static String getFullName(String code) {
		String regex = "public\\s+class\\s+(.*?)\\s+(\\{|implements|extends)";
		Pattern pattern = Pattern.compile(regex);
		Matcher matcher = pattern.matcher(code);
		if (matcher.find()) {
			return packageName + "." + matcher.group(1);
		}
		return null;
	}

	public static String getJavaCode(String code) {
		return "package\t" + packageName + ";\n\n" + code;
	}
}
